import {
	number
} from "./utils.js"
import $http from './http.js'

export const getAccountList = () => {
	return require('../data/account_list.json');
}

export const getAccountType = () => {
	return require('../data/account_type.json');
}

export const getBankList = () => {
	return require('../data/conf_bank.json');
}

export const getBank = (bankId) => {
	let list = require('../data/conf_bank.json');
	let bank = list.filter((item) => {
		return item.bankId == bankId
	});
	return bank[0];
}

export const getConfRepay = () => {
	return require('../data/conf_repay.json');
}

export const getConfDayList = () => {
	let dayList = [];
	for (let i = 1; i <= 28; i++) {
		let obj = {
			label: '每月' + i.toString() + "号",
			value: i
		};

		dayList.push(obj);
	}

	let endObj = {
		label: '月末',
		value: -1
	};

	dayList.push(endObj);
	return dayList;
}

export const addAccount = (account) => {
	
	account.balance = number(account.balance);
	account.limits = number(account.limits);
	
	return $http({
		url: 'update_account',
		data: account
	})
}
